//
//  LogisticsReslutViewController.m
//  FreightAssistant
//
//  Created by Mac mini on 15/12/11.
//  Copyright © 2015年 leo. All rights reserved.
//

#import "LogisticsReslutViewController.h"

@interface LogisticsReslutViewController () {
    
    NSString *_resultURL;
}

@end

@implementation LogisticsReslutViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.edgesForExtendedLayout = UIRectEdgeTop;
    self.navigationItem.title = @"查询结果";
    
    [self downLoadDataFromWeb];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - 

- (void)setOrderNumber:(NSString *)orderNumber type:(NSString *)type {
    
    if (orderNumber && type) {
        _resultURL = [NSString stringWithFormat: @"http://m.kuaidi100.com/index_all.html?type=%@&postid=%@#result", type, orderNumber];
    }
}

#pragma mark - Private methods

- (void)downLoadDataFromWeb {
    
    if (_resultURL == nil) {
        
        __weak typeof(self) weakSelf = self;
        [[KKAlertView shareInterce] showWithTitle: @"错误" andWithMessage: @"快递单号有误,暂无法查询到物流信息" andWithCancelTitle: nil andWithCancelHandle: nil andWithSureTitle: @"返回" andWithSureHandle:^{
            
            [weakSelf.navigationController popViewControllerAnimated: true];
        }];
        
        return;
    }
    
    [self.webView setAllowURLHost: @"m.kuaidi100.com"];
    [self setRequestURL: _resultURL];
}

@end
